/*
 * @Author: Tendo 
 * @Date: 2021-09-08 10:05:00 
 * @param {ListNode} head
 * @return {ListNode}
 * @desc 反转链表[双指针法]
 */

var reverseList = (head) => {
    if(!head || !head.next) return head;
    let cur = head,
        pre = null,
        temp;
    while(cur) {
        temp = cur.next; // 用temp节点保存 cur->next
        cur.next = pre; // 翻转操作
        // 更新pre 和 cur 指针
        pre = cur;
        cur = temp;
    }
    return pre
}